package data_structure;

public class leetcode_0700 {
    public static void main(String[] args) {
        TreeNode root=new TreeNode(3);
        root.left=new TreeNode(2);
        root.right=new TreeNode(5);
        searchBST(root,5);
    }
    public static TreeNode searchBST(TreeNode root, int val) {
        return dfs(root,val);
    }
    public static TreeNode dfs(TreeNode node ,int target){
        if(node==null) return null;
        if(node.val==target) return node;
        else if(node.val<target) return dfs(node.left,target);
        else return dfs(node.right,target);
    }
}
